home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 September / CHIP Eylül 1998.iso / Slackwar / docs / NIS-HOWTO < prev    next >
Text File  |  1998-01-15  |  39KB  |  972 lines

  1.   The Linux NIS(YP)/NYS/NIS+ HOWTO
  2.   Thorsten Kukuk
  3.   v0.9, 10. January 1998
  4.  
  5.   This document describes how to configure Linux as NIS(YP) or NIS+
  6.   client and how to install as NIS server.
  7.  
  8.   1.  Introduction
  9.  
  10.   More and more, Linux machines are installed as part of a network of
  11.   computers. To simplify network administration, most networks (mostly
  12.   Sun-based networks) run the Network Information Service. Linux
  13.   machines can take full advantage of existing NIS service or provide
  14.   NIS service themselves. Linux machines can also act as full NIS+
  15.   clients, this support is in beta stage.
  16.  
  17.   This document tries to answer questions about setting up NIS(YP) and
  18.   NIS+ on your Linux machine. Don't forget to read the section about
  19.   ``the RPC Portmapper''
  20.  
  21.   The NIS-Howto is edited and maintained by:
  22.  
  23.        Thorsten Kukuk, kukuk@vt.uni-paderborn.de
  24.  
  25.   The primary source of the information for the initial NIS-Howto was
  26.   from:
  27.  
  28.        Andrea Dell'Amico       <adellam@ZIA.ms.it>
  29.        Mitchum DSouza          <Mitch.DSouza@NetComm.IE>
  30.        Erwin Embsen            <erwin@nioz.nl>
  31.        Peter Eriksson          <peter@ifm.liu.se>
  32.  
  33.   who we should thank for writing the first versions of this document.
  34.  
  35.   1.1.  New versions of this document
  36.  
  37.   New versions of this document will be posted periodically to the
  38.   newsgroups  comp.os.linux.help <news:comp.os.linux.help> and
  39.   comp.os.linux.announce <news:comp.os.linux.announce>.  They will also
  40.   be uploaded to various Linux WWW and FTP sites, including the LDP home
  41.   page.
  42.  
  43.   You can always view the latest version of this on the World Wide Web
  44.   via the URL http://sunsite.unc.edu/mdw/HOWTO/NIS-HOWTO.html
  45.   <http://sunsite.unc.edu/mdw/HOWTO/NIS-HOWTO.html>.
  46.  
  47.   1.2.  Disclaimer
  48.  
  49.   Although this document has been put together to the best of our
  50.   knowledge it may, and probably does contain errors. Please read any
  51.   README files that are bundled with any of the various pieces of
  52.   software described in this document for more detailed and accurate
  53.   information. We will attempt to keep this document as error free as
  54.   possible.
  55.  
  56.   1.3.  Feedback and Corrections
  57.  
  58.   If you have questions or comments about this document, please feel
  59.   free to mail Thorsten Kukuk, at kukuk@vt.uni-paderborn.de. I welcome
  60.   any suggestions or criticisms. If you find a mistake with this
  61.   document, please let me know so I can correct it in the next version.
  62.   Thanks.
  63.  
  64.   Please do not mail me questions about special problems with your Linux
  65.   distributions! I don't know every Linux Distribution. But I will try
  66.   to add every solution you send me.
  67.  
  68.   1.4.  Acknowledgements
  69.  
  70.   We would like to thank all the people who have contributed (directly
  71.   or indirectly) to this document. In alphabetical order:
  72.  
  73.        Byron A Jeff            <byron@cc.gatech.edu>
  74.        Miquel van Smoorenburg  <miquels@cistron.nl>
  75.  
  76.   Theo de Raadt <deraadt@theos.com> is responsible for the original yp-
  77.   clients code.  Swen Thuemmler <swen@uni-paderborn.de> ported the yp-
  78.   clients code to Linux and also ported the yp-routines in libc (again
  79.   based on Theo's work). Thorsten Kukuk has written the NIS(YP) and NIS+
  80.   routines for GNU libc 2.x from scratch.
  81.  
  82.   2.  Glossary and General Information
  83.  
  84.   2.1.  Glossary of Terms
  85.  
  86.   In this document a lot of acronyms are used. Here are the most
  87.   important acronyms and a brief explanation:
  88.  
  89.      DBM
  90.         DataBase Management, a library of functions which maintain key-
  91.         content pairs in a data base.
  92.  
  93.      DLL
  94.         Dynamically Linked Library, a library linked to an executable
  95.         program at run-time.
  96.  
  97.      domainname
  98.         A name "key" that is used by NIS clients to be able to locate a
  99.         suitable NIS server that serves that domainname key. Please note
  100.         that this does not necessarily have anything at all to do with
  101.         the DNS "domain" (machine name) of the machine(s).
  102.  
  103.      FTP
  104.         File Transfer Protocol, a protocol used to transfer files
  105.         between two computers.
  106.  
  107.      libnsl
  108.         Name services library, a library of name service calls
  109.         (getpwnam, getservbyname, etc...) on SVR4 Unixes. GNU libc uses
  110.         this for the NIS (YP) and NIS+ functions.
  111.  
  112.      libsocket
  113.         Socket services library, a library for the socket service calls
  114.         (socket, bind, listen, etc...) on SVR4 Unixes.
  115.  
  116.      NIS
  117.         Network Information Service, a service that provides
  118.         information, that has to be known throughout the network, to all
  119.         machines on the network. There is support for NIS in Linux's
  120.         standard libc library, which in the following text is referred
  121.         to as "traditional NIS".
  122.  
  123.      NIS+
  124.         Network Information Service (Plus :-), essentially NIS on
  125.         steroids. NIS+ is designed by Sun Microsystems Inc. as a
  126.         replacement for NIS with better security and better handling of
  127.         _large_ installations.
  128.  
  129.      NYS
  130.         This is the name of a project and stands for NIS+, YP and Switch
  131.         and is managed by Peter Eriksson <peter@ifm.liu.se>. It contains
  132.         among other things a complete reimplementation of the NIS (= YP)
  133.         code that uses the Name Services Switch functionality of the NYS
  134.         library.
  135.  
  136.      NSS
  137.         Name Service Switch. The /etc/nsswitch.conf file determines the
  138.         order of lookups performed when a certain piece of information
  139.         is requested.
  140.  
  141.      RPC
  142.         Remote Procedure Call. RPC routines allow C programs to make
  143.         procedure calls on other machines across the network.  When
  144.         people talk about RPC they most often mean the Sun RPC variant.
  145.  
  146.      YP Yellow Pages(tm), a registered trademark in the UK of British
  147.         Telecom plc.
  148.  
  149.      TCP-IP
  150.         Transmission Control Protocol/Internet Protocol. It's the data
  151.         communication protocol most often used on Unix machines.
  152.  
  153.   2.2.  Some General Information
  154.  
  155.   The next four lines are quoted from the Sun(tm) System & Network
  156.   Administration Manual:
  157.  
  158.            "NIS was formerly known as Sun Yellow Pages (YP) but
  159.             the name Yellow Pages(tm) is a registered trademark
  160.             in the United Kingdom of British Telecom plc and may
  161.             not be used without permission."
  162.  
  163.   NIS stands for Network Information Service. Its purpose is to provide
  164.   information, that has to be known throughout the network, to all
  165.   machines on the network. Information likely to be distributed by NIS
  166.   is:
  167.  
  168.   ╖  login names/passwords/home directories (/etc/passwd)
  169.  
  170.   ╖  group information (/etc/group)
  171.  
  172.   So, for example, if your password entry is recorded in the NIS passwd
  173.   database, you will be able to login on all machines on the net which
  174.   have the NIS client programs running.
  175.  
  176.   Sun is a trademark of Sun Microsystems, Inc. licensed to SunSoft, Inc.
  177.  
  178.   3.  NIS or NIS+ ?
  179.  
  180.   The choice between NIS and NIS+ is easy - use NIS if you don't have to
  181.   use NIS+ or have severe security needs. NIS+ is _much_ more
  182.   problematic to administer (it's pretty easy to handle on the client
  183.   side, but the server side is horrible). Another problem is that the
  184.   support for NIS+ under Linux is still under developement - you need
  185.   the latest glibc snapshot for it or have to wait for glibc 2.1. There
  186.   is a port of the glibc NIS+ support for libc5 as drop in replacement.
  187.  
  188.   3.1.  libc 4/5 with traditional NIS or NYS ?
  189.  
  190.   The choice between "traditional NIS" or the NIS code in the NYS
  191.   library is a choice between laziness and maturity vs. flexibility and
  192.   love of adventure.
  193.  
  194.   The "traditional NIS" code is in the standard C library and has been
  195.   around longer and sometimes suffers from it's age and slight
  196.   inflexibility.
  197.  
  198.   The NIS code in the NYS library requires you to recompile the libc
  199.   library to include the NYS code into the libc library (or maybe you
  200.   can go get a precompiled version of libc from someone who has already
  201.   done it).
  202.  
  203.   Another difference is that the traditional NIS code has some support
  204.   for NIS Netgroups, which the NYS code doesn't (yet). On the other hand
  205.   the NYS code allows you to handle Shadow Passwords in a transparent
  206.   way. The "traditonal NIS" code doesn't support Shadow Passwords over
  207.   NIS.
  208.  
  209.   Forgot this all if you use the new GNU C Library 2.x (aka libc6). It
  210.   supports NSS (name switch service), which makes it very flexible, and
  211.   contains support for the following NIS/NIS+ maps: aliases, ethers,
  212.   group, hosts, netgroups, networks, protocols, publickey, passwd, rpc,
  213.   services and shadow.
  214.  
  215.   4.  How it works
  216.  
  217.   4.1.  How NIS(YP) works
  218.  
  219.   Within a network there must be at least one machine acting as a NIS
  220.   server. You can have multiple NIS servers, each serving different NIS
  221.   "domains" - or you can have cooperating NIS servers, where one is said
  222.   to be the master NIS server, and all the other are so-called slave NIS
  223.   servers (for a certain NIS "domain", that is!) - or you can have a mix
  224.   of them...
  225.  
  226.   Slave servers only have copies of the NIS databases and receive these
  227.   copies from the master NIS server whenever changes are made to the
  228.   master's databases.  Depending on the number of machines in your
  229.   network and the reliability of your network, you might decide to
  230.   install one or more slave servers.  Whenever a NIS server goes down or
  231.   is too slow in responding to requests, a NIS client connected to that
  232.   server will try to find one that is up or quicker.
  233.  
  234.   NIS databases are in so-called DBM format, derived from ASCII
  235.   databases.  For example, the files /etc/passwd and /etc/group can be
  236.   directly converted to DBM format using ASCII-to-DBM translation
  237.   software ("makedbm", it's included with the server software). The
  238.   master NIS server should have both, the ASCII databases and the DBM
  239.   databases.
  240.  
  241.   Slave servers  will be notified of any change to the NIS maps, (via
  242.   the "yppush" program), and automatically retrieve the necessary
  243.   changes in order to synchronize their databases. NIS clients do not
  244.   need to do this since they always talk to the NIS server to read the
  245.   information stored in it's DBM databases.
  246.  
  247.   The author of the YP clients for linux has informed us that the newest
  248.   ypbind (ypbind-3.3.tar.gz) is able to get the server from a
  249.   configuration file - thus no need to broadcast (which is insecure -
  250.   due to the fact that anyone may install a NIS server and answer the
  251.   broadcast queries...)
  252.  
  253.   4.2.  How NIS+ works
  254.  
  255.   NIS+ is a new version of the network information nameservice from Sun.
  256.   The biggest difference between NIS and NIS+ is, that NIS+ has support
  257.   for data encryption and authentication over secure RPC.
  258.  
  259.   The  naming  model of NIS+ is based upon a tree structure. Each node
  260.   in the tree corresponds to an NIS+ object, from which we have six
  261.   types: directory, entry, group, link, table and private.
  262.  
  263.   The NIS+ directory that forms the root of the NIS+ namespace is called
  264.   the root directory. There are two special NIS+ directories: org_dir
  265.   and groups_dir. The org_dir directory consists of all administration
  266.   tables, such as passwd, hosts, and mail_aliases. The groups_dir
  267.   directory consists of NIS+ group objects which are used for access
  268.   control. The collection of org_dir, groups_dir and their parent
  269.   directory is referred to as an NIS+ domain.
  270.  
  271.   5.  The RPC Portmapper
  272.  
  273.   To run any of the software mentioned below you will need to run the
  274.   program /usr/sbin/portmap. Some Linux distributions already have the
  275.   code in the /etc/rc.d/ files to start up this daemon.  All you have to
  276.   do is to activate it and reboot your Linux machine.  Read your Linux
  277.   Distribution Documentation how to do this.
  278.  
  279.   The RPC portmapper (portmap(8)) is a server that converts RPC program
  280.   numbers into TCP/IP (or UDP/IP) protocol port numbers. It must be
  281.   running in order to make RPC calls (which is what the NIS/NIS+ client
  282.   software does) to RPC servers (like a NIS or NIS+ server) on that
  283.   machine.  When an RPC server is started, it will tell portmap what
  284.   port number it is listening to, and what RPC program numbers it is
  285.   prepared to serve.  When a client wishes to make an RPC call to a
  286.   given program number, it will first contact portmap on the server
  287.   machine to determine the port number where RPC packets should be sent.
  288.   Normally, standard RPC servers are started by inetd(8), so portmap
  289.   must be started before inetd is invoked.
  290.  
  291.   For secure RPC, the portmapper needs the Time Service. Make sure, that
  292.   the Time Service is enabled in /etc/inetd.conf on all hosts:
  293.  
  294.        #
  295.        # Time service is used for clock syncronization.
  296.        #
  297.        time    stream  tcp     nowait  nobody  /usr/sbin/tcpd  in.timed
  298.        time    dgram   udp     wait    nobody  /usr/sbin/tcpd  in.timed
  299.  
  300.   IMPORTANT: Don't forget to restart inetd after changes on this file !
  301.  
  302.   6.  What do you need to set up NIS?
  303.  
  304.   6.1.  Determine whether you are a Server, Slave or Client.
  305.  
  306.   To answer this question you have to consider two cases:
  307.  
  308.   1. Your machine is going to be part of a network with existing NIS
  309.      servers
  310.  
  311.   2. You do not have any NIS servers in the network yet
  312.  
  313.   In the first case, you only need the client programs (ypbind, ypwhich,
  314.   ypcat, yppoll, ypmatch). The most important program is ypbind. This
  315.   program must be running at all times, that is, it should always appear
  316.   in the list of processes. It's a so-called daemon process and needs to
  317.   be started from the system's startup file (eg. /etc/rc.local,
  318.   /etc/init.d/nis, /etc/rc.d/init.d/ypbind).  As soon as ypbind is
  319.   running, your system has become a NIS client.
  320.  
  321.   In the second case, if you don't have NIS servers, then you will also
  322.   need a NIS server program (usually called ypserv). Section 8 describes
  323.   how to set up a NIS server on your Linux machine using the "ypserv"
  324.   implementation by Peter Eriksson and Thorsten Kukuk.  Note that from
  325.   version 0.14 this implementation supports the master-slave concept
  326.   talked about in section 4.1.
  327.  
  328.   There is also another free NIS server available, called "yps", written
  329.   by Tobias Reber in Germany which does support the master-slave
  330.   concept, but has other limitations and isn't supported any longer.
  331.  
  332.   6.2.  The Software
  333.  
  334.   The system library "/usr/lib/libc.a" (version 4.4.2 and better) or the
  335.   shared library "/lib/libc.so.x" contain all necessary system calls to
  336.   succesfully compile the NIS client and server software. For glibc 2.x,
  337.   you also need /lib/libnsl.so.1.
  338.  
  339.   Some people reported that NIS only works with "/usr/lib/libc.a"
  340.   version 4.5.21 and better so if you want to play it safe don't use
  341.   older libc's.  The NIS client software can be obtained from:
  342.  
  343.     Site                  Directory                        File Name
  344.  
  345.     ftp.uni-paderborn.de  /linux/local/yp                  yp-clients-2.2.tar.gz
  346.     ftp.uni-paderborn.de  /linux/local/yp                  ypbind-3.3.tar.gz
  347.     ftp.kernel.org        /pub/linux/utils/net/NIS         yp-tools-1.4.tar.gz
  348.     ftp.kernel.org        /pub/linux/utils/net/NIS         ypbind-3.3.tar.gz
  349.     sunsite.unc.edu       /pub/Linux/system/Network/admin  yp-clients-2.2.tar.gz
  350.  
  351.   Once you obtained the software, please follow the instructions which
  352.   come with the software. yp-clients 2.2 are for use with libc4 and
  353.   libc5 until 5.4.20. libc 5.4.21 and glibc 2.x needs yp-tools 1.4.
  354.   Since there was some bugs in the NIS code, you shouldn't use libc
  355.   5.4.21-5.4.35. Use libc 5.4.36 or later instead. ypbind 3.3 will work
  356.   with all libraries.  You should never use the ypbind from yp-clients
  357.   2.2.
  358.  
  359.   6.3.  The ypbind daemon
  360.  
  361.   Assuming you have succesfully compiled the software you are now ready
  362.   to install the software. A suitable place for the ypbind daemon is the
  363.   directory /usr/sbin. Some people may tell you, that you don't need
  364.   ypbind on a system with NYS. This is wrong, ypwhich and ypcat need it.
  365.  
  366.   You'll need to do this as root of course. The other binaries (ypwhich,
  367.   ypcat, yppoll, ypmatch) should go in a directory accessible by all
  368.   users, normally /usr/bin.
  369.  
  370.   The ypbind process has a configuration file called /etc/yp.conf. You
  371.   can hardcode a NIS server there - for more info see the manual page
  372.   for ypbind(8).  You also need this file for NYS.  An example:
  373.  
  374.          ypserver voyager
  375.          ypserver ds9
  376.  
  377.   If the system could resolv the hostnames without NIS, you could use
  378.   the name, else you have to use the IP address.
  379.  
  380.   It might be a good idea to test ypbind before  incorporating it in the
  381.   /etc/rc.d/ files. To test ypbind do the following:
  382.  
  383.   ╖  Make sure you have your domain name set. If it is not set then
  384.      issue the command:
  385.  
  386.                    /bin/domainname nis.domain
  387.  
  388.   where nis.domain should be some string, _NOT_ normally associated with
  389.   the domain name of your machine! The reason for this is that it makes
  390.   it a little harder for external crackers to retreive the password
  391.   database from your NIS servers. If you don't know what the NIS domain
  392.   name is on your network, ask your system/network administrator.
  393.  
  394.   ╖  Start up "/usr/sbin/portmap" if it is not already running.
  395.  
  396.   ╖  Create the directory "/var/yp" if it does not exist.
  397.  
  398.   ╖  Start up "/usr/sbin/ypbind"
  399.  
  400.   ╖  Use the command "rpcinfo -p localhost" to check if ypbind was able
  401.      to register its service with the portmapper. The rpcinfo should
  402.      produce something like:
  403.  
  404.               program vers proto   port
  405.                100000    2   tcp    111  portmapper
  406.                100000    2   udp    111  portmapper
  407.                100007    2   udp    637  ypbind
  408.                100007    2   tcp    639  ypbind
  409.                300019    1   udp    660
  410.  
  411.   ╖  You may also run "rpcinfo -u localhost ypbind". This command should
  412.      produce something like:
  413.  
  414.                program 100007 version 2 ready and waiting
  415.  
  416.   At this point you should be able to use NIS client programs like
  417.   ypcat, etc...  For example, "ypcat passwd" will give you the entire
  418.   NIS password database.
  419.  
  420.   IMPORTANT: If you skipped the test procedure then make sure you have
  421.   set the domain name, and created the directory:
  422.  
  423.            /var/yp
  424.  
  425.   This directory MUST exist for ypbind to start up succesfully.
  426.  
  427.   If the test worked you may now want to change the files in /etc/rc.d/
  428.   on your system so that ypbind will be started up at boot time and your
  429.   system will act as a NIS client. Make sure, that the domainname will
  430.   be set at boot time.
  431.  
  432.   Well, that's it. Reboot the machine and watch the boot messages to see
  433.   if ypbind is actually started.
  434.  
  435.   6.4.  Setting up a NIS Client using Traditional NIS
  436.  
  437.   For host lookups you must set (or add) "nis" to the lookup order line
  438.   in your /etc/host.conf file. Please read the manpage "resolv+.8" for
  439.   more details.
  440.  
  441.   Add the following line to /etc/passwd on your NIS clients:
  442.  
  443.        +::::::
  444.  
  445.   You can also use the + and - characters to include/exclude or change
  446.   users. If you want to exclude the user guest just add -guest to your
  447.   /etc/passwd file.  You want to use a different shell (e.g. ksh) for
  448.   the user "linux"?  No problem, just add "+linux::::::/bin/ksh"
  449.   (without the quotes) to your /etc/passwd. Fields that you don't want
  450.   to change have to be left empty. You could also use Netgroups for user
  451.   control.
  452.  
  453.   For example, to only allow login-access to miquels, dth and ed, and
  454.   all members of the sysadmin netgroup, but to have the account data of
  455.   all other users available:
  456.  
  457.              +miquels:::::::
  458.              +ed:::::::
  459.              +dth:::::::
  460.              +@sysadmins:::::::
  461.              -ftp
  462.              +:*::::::/etc/NoShell
  463.  
  464.   Note that in Linux you can also override the password field, as we did
  465.   in this example. In this example, we also remove the login "ftp", so
  466.   it isn't known any longer, and anonymous ftp will not work.
  467.  
  468.   The netgroup would be look like
  469.  
  470.        sysadmins (-,software,) (-,kukuk,)
  471.  
  472.   IMPORTANT: Note that the netgroup  feature is implemented starting
  473.   from libc 4.5.26. But if you have a version of libc earlier than
  474.   4.5.26, every user in the NIS password database can access your linux
  475.   machine if you run "ypbind".
  476.  
  477.   6.5.  Setting up a NIS Client using NYS
  478.  
  479.   All that is required is that the NIS configuration file (/etc/yp.conf)
  480.   points to the correct server(s) for its information.  Also, the Name
  481.   Services Switch configuration file (/etc/nsswitch.conf) must be
  482.   correctly set up.
  483.  
  484.   You should install ypbind. It isn't needed by the libc, but the
  485.   NIS(YP) tools need it.
  486.  
  487.   If you wish to use the include/exclude user feature
  488.   (+/-guest/+@admins), you have to use "passwd: compat" and "group:
  489.   compat". Note, that there is no "shadow: compat" ! You have to use
  490.   "shadow: files nis" in this case.
  491.  
  492.   The NYS sources are part of the libc 5 sources. When run configure,
  493.   say the first time "NO" to the "Values correct" question, then say
  494.   "YES" to "Build a NYS libc from nys".
  495.  
  496.   6.6.  Setting up a NIS Client using glibc 2.x
  497.  
  498.   The glibc uses "traditional NIS", so you need to start ypbind. The
  499.   Name Services Switch configuration file (/etc/nsswitch.conf) must be
  500.   correctly set up. If you use the compat mode for passwd, shadow or
  501.   group, you have to add the "+" at the end of this files, and you could
  502.   use the include/exclude user feature. The configuration is excatly the
  503.   same as under Solaris 2.x.
  504.  
  505.   6.7.  The nsswitch.conf File
  506.  
  507.   The Network Services switch file /etc/nsswitch.conf determines the
  508.   order of lookups performed when a certain piece of information is
  509.   requested, just like the /etc/host.conf file which determines the way
  510.   host lookups are performed. For example, the line
  511.  
  512.            hosts: files nis dns
  513.  
  514.   specifies that host lookup functions should first look in the local
  515.   /etc/hosts file, followed by a NIS lookup and finally thru the domain
  516.   name service (/etc/resolv.conf and named), at which point if no match
  517.   is found an error is returned.
  518.  
  519.   A first version of a manual page for nsswitch.conf could be found at
  520.   http://www-vt.uni-paderborn.de/~kukuk/linux/misc.html <http://www-
  521.   vt.uni-paderborn.de/~kukuk/linux/misc.html>.
  522.  
  523.   A good /etc/nsswitch.conf file for NIS is:
  524.  
  525.   #
  526.   # /etc/nsswitch.conf
  527.   #
  528.   # An example Name Service Switch config file. This file should be
  529.   # sorted with the most-used services at the beginning.
  530.   #
  531.   # The entry '[NOTFOUND=return]' means that the search for an
  532.   # entry should stop if the search in the previous entry turned
  533.   # up nothing. Note that if the search failed due to some other reason
  534.   # (like no NIS server responding) then the search continues with the
  535.   # next entry.
  536.   #
  537.   # Legal entries are:
  538.   #
  539.   #       nisplus                 Use NIS+ (NIS version 3)
  540.   #       nis                     Use NIS (NIS version 2), also called YP
  541.   #       dns                     Use DNS (Domain Name Service)
  542.   #       files                   Use the local files
  543.   #       db                      Use the /var/db databases
  544.   #       [NOTFOUND=return]       Stop searching if not found so far
  545.   #
  546.  
  547.   passwd:     compat
  548.   group:      compat
  549.   shadow:     compat
  550.  
  551.   passwd_compat: nis
  552.   group_compat: nis
  553.   shadow_compat: nis
  554.  
  555.   hosts:      nis files dns
  556.  
  557.   services:   nis [NOTFOUND=return] files
  558.   networks:   nis [NOTFOUND=return] files
  559.   protocols:  nis [NOTFOUND=return] files
  560.   rpc:        nis [NOTFOUND=return] files
  561.   ethers:     nis [NOTFOUND=return] files
  562.   netmasks:   nis [NOTFOUND=return] files
  563.   netgroup:   nis
  564.   bootparams: nis [NOTFOUND=return] files
  565.   publickey:  nis [NOTFOUND=return] files
  566.   automount:  files
  567.   aliases:    nis [NOTFOUND=return] files
  568.  
  569.   passwd_compat, group_compat and shadow_compat are only supported by
  570.   glibc 2.x.  If there are no shadow rules in /etc/nsswitch.conf, glibc
  571.   will use the passwd rule for lookups. There are some more lookup
  572.   module for glibc like hesoid.  For more information, read the glibc
  573.   documentation.
  574.  
  575.   7.  What do you need to set up NIS+ ?
  576.  
  577.   7.1.  The Software
  578.  
  579.   The Linux NIS+ client code was developed for the GNU C library 2.
  580.   There is also a port for Linux libc5, since all commercial Applicatons
  581.   are linked against this library, and you couldn't recompile them for
  582.   using glibc. There are problems with libc5 + NIS+: You couldn't link
  583.   static programs with it, and programs compiled with this library will
  584.   not work with other libc5 versions.
  585.  
  586.   You need to retrieve and compile the latest GNU C library 2 snapshot.
  587.   And you need a glibc based system like RedHat 5.0 or the unstable
  588.   Debian. But be warned: This are all beta Software ! Read the Docs
  589.   about glibc snapshots and from the Distributions ! glibc 2.0.x doesn't
  590.   contain the NIS+ support, and will never contain it. The first public
  591.   version with NIS+ support will be 2.1.
  592.  
  593.   The NIS+ client software can be obtained from:
  594.  
  595.          Site                   Directory                  File Name
  596.  
  597.          ftp.kernel.org         /pub/software/libs/glibc   libc-*, glibc-crypt-*,
  598.                                                            glibc-linuxthreads-*
  599.          ftp.kernel.org         /pub/linux/utils/net/NIS+  nis-tools-1.4.tar.gz
  600.          ftp.kernel.org         /pub/linux/utils/net/NIS+  pam_keylogin-1.1.tar.gz
  601.  
  602.   Distributions based on glibc can be fetched from:
  603.  
  604.          Site                   Directory
  605.  
  606.          ftp.redhat.com         /pub/redaht/mustang
  607.          ftp.debian.org         /pub/debian/hamm
  608.  
  609.   For compilation of the GNU C Library, please follow the instructions
  610.   which come with the software. Here you could find the patched libc5,
  611.   based on NYS and the glibc sources as drop in replacement for the
  612.   standart libc5:
  613.  
  614.          Site               Directory                  File Name
  615.  
  616.          ftp.kernel.org     /pub/linux/utils/net/NIS+  libc-5.4.38-nsl-0.4.6.tar.gz
  617.  
  618.   You should also look at http://www-vt.uni-
  619.   paderborn.de/~kukuk/linux/nisplus.html <http://www-vt.uni-
  620.   paderborn.de/~kukuk/linux/nisplus.html> for more information and the
  621.   latest sources.
  622.  
  623.   7.2.  Setting up a NIS+ client
  624.  
  625.   IMPORTANT: For setting up a NIS+ client, read your Solaris NIS+ docs
  626.   what to do on the server side ! This document only describes what to
  627.   do on the client side !
  628.  
  629.   After installing the new libc and nis-tools, create the credentials
  630.   for the new client on the NIS+ server. Then run
  631.  
  632.        domainname nisplus.domain.
  633.        nisinit -c -H <NIS+ server>
  634.  
  635.   to initialize the cold Start File. Read the nisinit man page for more
  636.   options. Make sure, that the domainname will always be set after a
  637.   reboot.  If you don't know what the NIS+ domain name is on your
  638.   network, ask your system/network administrator.
  639.  
  640.   Now you should change your /etc/nsswitch.conf file. Make sure, that
  641.   the only service after publickey is nisplus ("publickey: nisplus"),
  642.   and nothing else !
  643.  
  644.   After this, start keyserv and make sure, that it will always be
  645.   started at boot time. Run
  646.  
  647.        keylogin -r
  648.  
  649.   to store the root secretkey on your system. (I hope you have added the
  650.   publickey for the new host on the NIS+ Server ?).
  651.  
  652.   "niscat passwd.org_dir" should now show you all entries in the passwd
  653.   database.
  654.  
  655.   7.3.  NIS+, keylogin, login and PAM
  656.  
  657.   When the user logs in, he need to set his secretkey to keyserv. This
  658.   is done by calling "keylogin". The login from the shadow package will
  659.   do this for the user. For a PAM aware login, you have to install
  660.   pam_keylogin-1.1.tar.gz and change the /etc/pam.d/login file to use
  661.   pam_unix_auth, not pwdb, which doesn't support NIS+. An example:
  662.  
  663.        #%PAM-1.0
  664.        auth       required     /lib/security/pam_securetty.so
  665.        auth       required     /lib/security/pam_keylogin.so
  666.        auth       required     /lib/security/pam_unix_auth.so
  667.        auth       required     /lib/security/pam_nologin.so
  668.        account    required     /lib/security/pam_unix_acct.so
  669.        password   required     /lib/security/pam_unix_passwd.so
  670.        session    required     /lib/security/pam_unix_session.so
  671.  
  672.   7.4.  The nsswitch.conf File
  673.  
  674.   The Network Services switch file /etc/nsswitch.conf determines the
  675.   order of lookups performed when a certain piece of information is
  676.   requested, just like the /etc/host.conf file which determines the way
  677.   host lookups are performed. For example, the line
  678.  
  679.            hosts: files nisplus dns
  680.  
  681.   specifies that host lookup functions should first look in the local
  682.   /etc/hosts file, followed by a NIS+ lookup and finally thru the domain
  683.   name service (/etc/resolv.conf and named), at which point if no match
  684.   is found an error is returned.
  685.  
  686.   A first version of a manual page for nsswitch.conf could be found at
  687.   http://www-vt.uni-paderborn.de/~kukuk/linux/misc.html <http://www-
  688.   vt.uni-paderborn.de/~kukuk/linux/misc.html>.
  689.  
  690.   A good /etc/nsswitch.conf file for NIS+ is:
  691.  
  692.        #
  693.        # /etc/nsswitch.conf
  694.        #
  695.        # An example Name Service Switch config file. This file should be
  696.        # sorted with the most-used services at the beginning.
  697.        #
  698.        # The entry '[NOTFOUND=return]' means that the search for an
  699.        # entry should stop if the search in the previous entry turned
  700.        # up nothing. Note that if the search failed due to some other reason
  701.        # (like no NIS server responding) then the search continues with the
  702.        # next entry.
  703.        #
  704.        # Legal entries are:
  705.        #
  706.        #       nisplus                 Use NIS+ (NIS version 3)
  707.        #       nis                     Use NIS (NIS version 2), also called YP
  708.        #       dns                     Use DNS (Domain Name Service)
  709.        #       files                   Use the local files
  710.        #       db                      Use the /var/db databases
  711.        #       [NOTFOUND=return]       Stop searching if not found so far
  712.        #
  713.  
  714.        passwd:     compat
  715.        # for libc5: passwd: files nisplus
  716.        group:      compat
  717.        # for libc5: group: files nisplus
  718.        shadow:     compat
  719.        # for libc5: shadow: files nisplus
  720.  
  721.        passwd_compat: nisplus
  722.        group_compat:  nisplus
  723.        shadow_compat: nisplus
  724.  
  725.        hosts:      nisplus files dns
  726.  
  727.        services:   nisplus [NOTFOUND=return] files
  728.        networks:   nisplus [NOTFOUND=return] files
  729.        protocols:  nisplus [NOTFOUND=return] files
  730.        rpc:        nisplus [NOTFOUND=return] files
  731.        ethers:     nisplus [NOTFOUND=return] files
  732.        netmasks:   nisplus [NOTFOUND=return] files
  733.        netgroup:   nisplus
  734.        bootparams: nisplus [NOTFOUND=return] files
  735.        publickey:  nisplus
  736.        automount:  files
  737.        aliases:    nisplus [NOTFOUND=return] files
  738.  
  739.   8.  Setting up a NIS Server
  740.  
  741.   8.1.  The Server Program ypserv
  742.  
  743.   This document only describes how to set up the "ypserv" NIS server.
  744.  
  745.   The NIS server software can be found on:
  746.  
  747.          Site                   Directory                     File Name
  748.  
  749.          ftp.kernel.org         /pub/linux/utils/net/NIS      ypserv-1.2.7.tar.gz
  750.          waaug.erols.com        /pub/net/nis                  ypserv-1.2.7.tar.gz
  751.  
  752.   You could also look at http://www-vt.uni-
  753.   paderborn.de/~kukuk/linux/nis.html <http://www-vt.uni-
  754.   paderborn.de/~kukuk/linux/nis.html> for more information and the
  755.   latest sources.
  756.  
  757.   The server setup is the same for both traditional NIS and NYS.
  758.  
  759.   Compile the software to generate the "ypserv" and "makedbm" programs.
  760.   If you run your server as master, determine what files you require to
  761.   be available via NIS and then add or remove the appropriate entries to
  762.   the /var/yp/Makefile.
  763.  
  764.   Now edit /var/yp/securenets and /etc/ypserv.conf.  For more
  765.   information, read the ypserv(8) and ypserv.conf(5) manual pages.
  766.  
  767.   Make sure the portmapper (portmap(8)) is running, and start the server
  768.   "ypserv". The command
  769.  
  770.            % rpcinfo -u localhost ypserv
  771.  
  772.   should output something like
  773.  
  774.            program 100004 version 2 ready and waiting
  775.  
  776.   Now generate the NIS (YP) database. On the master, run
  777.  
  778.            % /usr/lib/yp/ypinit -m
  779.  
  780.   on a slave, make sure that ypwhich -m works. Then run
  781.  
  782.            % /usr/lib/yp/ypinit -s masterhost
  783.  
  784.   That's it, your server is up and running.
  785.  
  786.   You might want to edit root's crontab *on the slave* server and add
  787.   the following lines:
  788.  
  789.              20 *    * * *    /usr/lib/yp/ypxfr_1perhour
  790.              40 6    * * *    /usr/lib/yp/ypxfr_1perday
  791.              55 6,18 * * *    /usr/lib/yp/ypxfr_2perday
  792.  
  793.   This will ensure that most NIS maps are kept up-to-date, even if an
  794.   update is missed because the slave was down at the time the update was
  795.   done on the master.
  796.  
  797.   If you want to restrict access to your NIS server, you'll have to
  798.   setup the NIS server as a client as well by running ypbind and adding
  799.   the plus-entries to /etc/passwd _halfway_ the password file. The
  800.   library functions will ignore all normal entries after the first NIS
  801.   entry, and will get the rest of the info through NIS. This way the NIS
  802.   access rules are maintained. example:
  803.  
  804.             root:x:0:0:root:/root:/bin/bash
  805.             daemon:*:1:1:daemon:/usr/sbin:
  806.             bin:*:2:2:bin:/bin:
  807.             sys:*:3:3:sys:/dev:
  808.             sync:*:4:100:sync:/bin:/bin/sync
  809.             games:*:5:100:games:/usr/games:
  810.             man:*:6:100:man:/var/catman:
  811.             lp:*:7:7:lp:/var/spool/lpd:
  812.             mail:*:8:8:mail:/var/spool/mail:
  813.             news:*:9:9:news:/var/spool/news:
  814.             uucp:*:10:50:uucp:/var/spool/uucp:
  815.             nobody:*:65534:65534:noone at all,,,,:/dev/null:
  816.             +miquels::::::
  817.             +:*:::::/etc/NoShell
  818.             [ All normal users AFTER this line! ]
  819.             tester:*:299:10:Just a test account:/tmp:
  820.             miquels:1234567890123:101:10:Miquel van Smoorenburg:/home/miquels:/bin/zsh
  821.  
  822.   The user tester will exist, but have a shell of /etc/NoShell. miquels
  823.   will have normal access.
  824.  
  825.   Alternatively, you could edit the /var/yp/Makefile file and set NIS to
  826.   use another source password file. On big systems, the NIS password and
  827.   group files are usually stored in /var/yp/ypfiles/. If you do this the
  828.   normal tools to administrate the password file such as "passwd",
  829.   "chfn", "adduser" will not work anymore and you will need special
  830.   homemade tools for this.
  831.  
  832.   However yppasswd, ypchsh and ypchfn will work ofcourse.
  833.  
  834.   8.2.  The Server Program yps
  835.  
  836.   To set up the "yps" NIS server please refer to the previous paragraph.
  837.   The "yps" server setup is similar, _but_ not exactly the same so
  838.   beware if you try to apply the "ypserv" instructions to "yps"!  "yps"
  839.   is not supported by any author, and contains some security leaks.  You
  840.   shouldn't really use it !
  841.  
  842.   The "yps" NIS server software can be found on:
  843.  
  844.          Site                Directory                         File Name
  845.  
  846.          ftp.kernel.org      /pub/linux/utils/net/NIS          yps-0.21.tar.gz
  847.          ftp.lysator.liu.se  /pub/NYS/servers                  yps-0.21.tar.gz
  848.  
  849.   8.3.  The Program rpc.yppasswdd
  850.  
  851.   Whenever users change their passwords, the NIS password database and
  852.   probably other NIS databases, which depend on the NIS password
  853.   database, should be updated.  The program "rpc.yppasswdd" is a server
  854.   that handles password changes and makes sure that the NIS information
  855.   will be updated accordingly. rpc.yppasswdd is now integrated in ypserv
  856.   1.2.7. You don't need the older, separate yppasswd-0.9.tar.gz or
  857.   yppasswd-0.10.tar.gz, and you shouldn't use them any longer. The
  858.   rpc.yppasswdd in ypserv 1.2.7 has full shadow support. yppasswd is now
  859.   part of yp-tools-1.4.tar.gz,
  860.  
  861.   You need to start rpc.yppasswdd only on the NIS master server. By
  862.   default, users are not allowed to change their full name or the login
  863.   shell.  You could allow this with the -e chfn or -e chsh option.
  864.  
  865.   9.  Verifying the NIS/NYS Installation
  866.  
  867.   If everything is fine (as it should be), you should be able to verify
  868.   your installation with a few simple commands. Assuming, for example,
  869.   your passwd file is being supplied by NIS, the command
  870.  
  871.            % ypcat passwd
  872.  
  873.   should give you the contents of your NIS passwd file. The command
  874.  
  875.            % ypmatch userid passwd
  876.  
  877.   (where userid is the login name of an arbitrary user) should give you
  878.   the user's entry in the NIS passwd file. The "ypcat" and "ypmatch"
  879.   programs should be included with your distribution of traditional NIS
  880.   or NYS.
  881.  
  882.   If a user couldn't log in, run the following program on the client:
  883.  
  884.   #include <stdio.h>
  885.   #include <pwd.h>
  886.   #include <sys/types.h>
  887.  
  888.   int
  889.   main(int argc, char *argv[])
  890.   {
  891.     struct passwd *pwd;
  892.  
  893.     if(argc != 2)
  894.       {
  895.         fprintf(stderr,"Usage: getwpnam username\n");
  896.         exit(1);
  897.       }
  898.  
  899.     pwd=getpwnam(argv[1]);
  900.  
  901.     if(pwd != NULL)
  902.       {
  903.         printf("name.....: [%s]\n",pwd->pw_name);
  904.         printf("password.: [%s]\n",pwd->pw_passwd);
  905.         printf("user id..: [%d]\n", pwd->pw_uid);
  906.         printf("group id.: [%d]\n",pwd->pw_gid);
  907.         printf("gecos....: [%s]\n",pwd->pw_gecos);
  908.         printf("directory: [%s]\n",pwd->pw_dir);
  909.         printf("shell....: [%s]\n",pwd->pw_shell);
  910.       }
  911.     else
  912.       fprintf(stderr,"User \"%s\" not found!\n",argv[1]);
  913.  
  914.     exit(0);
  915.   }
  916.  
  917.   Running this program with the username as parameter, will print all
  918.   the information the getpwnam function will give back for this user.
  919.   This should show you, which entry is incorrect. The most common
  920.   problem is, that the password field is overwritten with a "*".
  921.  
  922.   10.  Common Problems and Troubleshooting NIS
  923.  
  924.   Here are some common problems reported by various users:
  925.  
  926.   1. The libraries for 4.5.19 are broken. NIS won't work with it.
  927.  
  928.   2. If you upgrade the libraries from 4.5.19 to 4.5.24 then the su
  929.      command breaks. You need to get the su command from the slackware
  930.      1.2.0 distribution. Incidentally that's where you can get the
  931.      updated libraries.
  932.  
  933.   3. You could run into trouble with NIS and DNS on the same machine
  934.      using an old a.out distribution. The DNS server occasionally will
  935.      not bring up NIS.
  936.  
  937.   4. When a NIS server goes down and comes up again ypbind starts
  938.      complaining with messages like:
  939.  
  940.               yp_match: clnt_call:
  941.                           RPC: Unable to receive; errno = Connection refused
  942.  
  943.   and logins are refused for those who are registered in the NIS
  944.   database. Try to login as root and if you succeed, then kill ypbind
  945.   and start it up again. An update to ypbind 3.3 or higher should also
  946.   help.
  947.  
  948.   5. After upgrade the libc to a version greater then 5.4.20, the YP
  949.      tools will not work any longer. You need yp-tools 1.2 or later for
  950.      libc >= 5.4.21 and glibc 2.x and yp-clients 2.2. for earlier
  951.      versions.
  952.  
  953.   6. In libc 5.4.21 - 5.4.35 yp_maplist is broken, you need 5.4.36 or
  954.      later for yp-tools 1.x.
  955.  
  956.   7. libc 5 with traditional NIS doesn't support shadow passwords over
  957.      NIS.  You need libc5 + NYS or glibc 2.x.
  958.  
  959.   11.  Frequently Asked Questions
  960.  
  961.   Most of your questions should be answered by now. If there are still
  962.   questions unanswered you might want to post a message to
  963.  
  964.            comp.os.linux.help
  965.  
  966.   or
  967.  
  968.            comp.os.linux.networking
  969.  
  970.   or contact one of the authors of this HOWTO.
  971.  
  972.